package com.leetcode.partition4;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

/**
 * @author `RKC`
 * @date 2022/2/17 10:19
 */
public class LC327区间和的个数_树状数组 {

    private static final int N = 300010;
    private static long[] sum = new long[N];
    private static int[] c = new int[N];
    private static Set<Long> set = new TreeSet<>();
    private static Map<Long, Integer> map = new HashMap<>();
    private static int n = 0, cnt = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        int n = Integer.parseInt(ss[0]), lower = Integer.parseInt(ss[1]), upper = Integer.parseInt(ss[2]);
        int[] nums = new int[n];
        ss = reader.readLine().split(" ");
        for (int i = 0; i < n; i++) nums[i] = Integer.parseInt(ss[i]);
        writer.write(countRangeSum(nums, lower, upper) + "\n");
        writer.flush();
    }

    public static int countRangeSum(int[] nums, int lower, int upper) {
        n = nums.length;
        for (int i = 1; i <= n; i++) sum[i] += sum[i - 1] + nums[i - 1];
        //对前缀和进行有序离散化
        for (int i = 0; i <= n; i++) {
            set.add(sum[i]);
            set.add(sum[i] - lower);
            set.add(sum[i] - upper);
        }
        int ans = 0;
        for (long s : set) map.put(s, ++cnt);
        for (int i = 0; i <= n; i++) {
            long s = sum[i];
            //找到左区间和右区间，通过线段树计算当前区间满足条件的数量
            int l = map.get(s - upper), r = map.get(s - lower), pos = map.get(s);
            ans += ask(r) - ask(l - 1);
            add(pos, 1);
        }
        return ans;
    }

    private static int ask(int x) {
        int res = 0;
        for (int i = x; i != 0; i -= lowbit(i)) res += c[i];
        return res;
    }

    private static void add(int x, int k) {
        for (int i = x; i <= cnt; i += lowbit(i)) c[i] += k;
    }

    private static int lowbit(int x) {
        return x & -x;
    }
}
